package com.macrounion.atv.controller.api;

import com.macrounion.atv.service.dto.req.DeleteProtocolcsReqDto;
import com.macrounion.atv.service.dto.req.SmartImportReqDto;
import com.macrounion.atv.service.dto.resp.SmartInsertRespDto;
import com.macrounion.atv.service.entity.ext.ProtocolCExt;
import com.macrounion.base.service.dto.BaseRespDto;
import com.macrounion.base.service.dto.PageRespDto;
import com.macrounion.base.service.dto.StringRespDto;
import org.springframework.web.bind.annotation.*;

import com.macrounion.atv.processor.ProtocolCProcessor;
import com.macrounion.atv.service.entity.ProtocolC;
import com.macrounion.atv.service.entity.User;
import com.macrounion.atv.service.service.ProtocolCService;
import com.macrounion.base.controller.api.BaseApiController;

@RestController
@RequestMapping("/api/protocolc")
public class ProtocolCApiController extends BaseApiController<ProtocolC, ProtocolC, ProtocolCProcessor, ProtocolCService, ProtocolC, User> {

    @PostMapping("/deleteRows")
    public int deleteRows(@RequestBody DeleteProtocolcsReqDto req) {
        return processor.deleteRows(req.getProtocolId(), req.getProtocolcIds());
    }

    @PostMapping("/smartImport")
    public SmartInsertRespDto smartImport(@RequestBody SmartImportReqDto reqDto) {
        return processor.smartImport(reqDto.getDeviceCode(), reqDto.getProtocolId(), reqDto.getProtocolName(), reqDto.getProtocolCIds());
    }

    @GetMapping("/getMaxChannel")
    public StringRespDto getMaxChannelCodeByProtocolId(String protocolId, Integer trap) {
        return new StringRespDto(processor.getMaxChannelCodeByProtocolId(protocolId, trap));
    }

    @GetMapping("/getCountByMid")
    public int getCountByMid(String mid, String protocolId) {
        return processor.getCountByMid(mid, protocolId);
    }

    @GetMapping("/getCountByChannelCode")
    public int getCountByChannelCode(String channelCode, String protocolId) {
        return processor.getCountByChannelCode(channelCode, protocolId);
    }

    @PostMapping("/saveAProtocolc")
    public StringRespDto saveAProtocolc(@RequestBody ProtocolC req) {
        return processor.saveAProtocolc(req.getProtocolId(), req);
    }

    @PostMapping("/updateTranslate")
    public BaseRespDto<String> updateTranslate(@RequestBody ProtocolC protocolC){
        return processor.updateTranslate(protocolC.getProtocolId(), protocolC);
    }

    @PostMapping("/requestPageExt")
    public PageRespDto<ProtocolCExt> requestPageExt(@RequestBody ProtocolC req){
        return processor.requestPageExt(req);
    }

}